package com.lekang.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.system.service.IContractService;

/**
 * 手动合同状态更新控制器
 * 用于测试和手动触发合同状态更新
 * 
 * @author 刘卓
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/system/contract/manual")
public class ManualContractStatusUpdateController extends BaseController
{
    @Autowired
    private IContractService contractService;

    /**
     * 手动更新合同状态
     */
    @PostMapping("/updateStatus")
    public AjaxResult updateContractStatus()
    {
        try
        {
            int updateCount = contractService.updateContractStatus();
            return success("合同状态更新完成，共更新 " + updateCount + " 条记录");
        }
        catch (Exception e)
        {
            logger.error("手动更新合同状态失败", e);
            return error("更新失败：" + e.getMessage());
        }
    }
}
